<script setup>
import { ref } from 'vue'
import emitter from '@/utils/emitter'
let toy = ref('挖掘机')

function sendToy() {
  // 发送玩具
  emitter.emit('toy', toy.value)
  console.log("哥哥发送了玩具");
  
}
</script>
<template>
  <div class="mychild">
    <h3>哥哥组件</h3>
    <h4>玩具:{{toy}}</h4>
    <el-button type="primary" @click="sendToy">给弟弟玩具</el-button>
    </div>
</template>
<style scoped>
.mychild {
  background-color: #378ec4;
  padding: 10px;
  border: 1px solid #000;
}
</style>